<?php
/**
* webuploader 通用上传组件
* 
* 
*/


$pat = '/\[(.*?)\]/i';   
  

//$src = Yii::app()->getController()->getAction()->id == 'Create' ? Yii::app()->request->baseUrl.'/static\common\img/image.png' : Yii::app()->controller->root_dir.'/'.$value;


$formData = array(
    '_csrf'=>Yii::$app->request->csrfToken,
	//'thumbWidth'=> isset($setting['thumb_width']) ? $setting['thumb_width'] : ''
);

?>

<div id="webuploader-container-<?php echo $id;?>">
    <ul class="webuploader-filelist webuploader-uploadImage" id="webuploader-filelist-<?php echo $id;?>">
        <li id="{$id}" class="image hidden"><p class="div120x90"><img class="webuploader-image" src="<?php echo Yii::$app->controller->root_dir.'/'?>/static/common/images/loading.gif"><span class="webuploader-del">－</span></p>
        
        </li>
        <?php if($value) foreach(explode(',',$value) as $k=>$img){
		?>
        <li class="image"><p class="div120x90"><img class="webuploader-image" src="<?php echo Yii::$app->controller->root_dir.'/'.$img;?>" value="<?php echo $img?>"><span class="webuploader-del">－</span></p>
        <input type="text" class="hidden" name="webuploader-<?php echo $id?>" value="<?php echo $img;?>"/>
        </li>
        <?php
		}
		?>
        <li id="uploadThumbImage_<?php echo $id;?>" class="webuploader-add"><a href="">+</a></li>
        
    </ul>
    <input type="text" class="hidden" name="<?php echo $name?>" id="<?php echo $id?>" value="<?php echo $value?>"/>
    <p class="validate-error" id="validate-error-<?php echo $id?>"></p>
    
    
</div>
<script>
$(function(){
webuploader_image({
	container: '#webuploader-container-<?php echo $id;?>',
	id:'#uploadThumbImage_<?php echo $id;?>',
	input:"#<?php echo $id;?>",
	multiple:<?php echo isset($param['num']) && $param['num']>1 ? 'true' : 'false'?>,
    num: <?php echo isset($param['num']) && $param['num'] ? $param['num'] : '1'?>,
	url:'<?php echo Yii::$app->controller->createUrl('/ueditor/upload');?>',
	formData:<?php echo json_encode($formData);?>, 
});
});
</script>